import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiVolumePage(Base):
    """
    语音训练语音页(音量页)

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的返回键
        self.volume_back_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivBack'))

        # 左侧的home键
        self.volume_home_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format('ivHome'))

        # 媒体标题
        self.volume_title_text = (By.XPATH, Yomi.volume_title_text.format(""))

        # 媒体初始音量
        self.volume_initial_text = (By.XPATH, Yomi.volume_initial_text.format(""))

        # 媒体音量条
        self.volume_select_icon = (By.XPATH, Yomi.volume_icon.format(""))

        # 媒体最大音量
        self.volume_initial_max_text = (By.XPATH, Yomi.volume_initial_max_text.format(""))

        # 确认按钮
        self.volume_sure_btn = (By.XPATH, Yomi.volume_sure_btn.format(""))

        # 文案提示
        self.volume_tip_text = (By.XPATH, Yomi.volume_tip_text.format(""))

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.volume_back_btn)

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.volume_home_btn)

    def get_title(self, index=1):
        """
        获取媒体标题

        :return:获取元素
        """
        self.volume_title_text = (By.XPATH, Yomi.volume_title_text.format(index))
        return self.find_element_o(self.volume_title_text)

    def get_initial(self, index=2):
        """
        获取媒体初始音量

        :return:获取元素
        """
        self.volume_initial_text = (By.XPATH, Yomi.volume_initial_text.format(index))
        return self.find_element_o(self.volume_initial_text)

    def get_select(self, index=1):
        """
        获取媒体音量条

        :return:获取元素
        """
        self.volume_select_icon = (By.XPATH, Yomi.volume_icon.format(index))
        return self.find_element_o(self.volume_select_icon)

    def get_initial_max(self, index=4):
        """
        获取媒体最大音量

        :return:获取元素
        """
        self.volume_initial_max_text = (By.XPATH, Yomi.volume_initial_max_text.format(index))
        return self.find_element_o(self.volume_initial_max_text)

    def click_sure(self, index=1):
        """
        点击确认按钮

        :return:获取元素
        """
        self.volume_sure_btn = (By.XPATH, Yomi.volume_sure_btn.format(index))
        self.click_element(self.volume_sure_btn)

    def get_tip(self, index=6):
        """
        获取文案提示

        :return:获取元素
        """
        self.volume_tip_text = (By.XPATH, Yomi.volume_tip_text.format(index))
        return self.find_element_o(self.volume_tip_text)

    def is_display_yomi_volume(self, index=1):
        """
        查看是否媒体音量页

        :return:
        """
        self.volume_title_text = (By.XPATH, Yomi.volume_title_text.format(index))
        return self.is_display(self.volume_title_text)
